import numpy as np
import tensorflow.compat.v2 as tf
tf.enable_v2_behavior()
import pandas as pd
from tensorflow import keras
from sklearn.preprocessing import StandardScaler
from sklearn.preprocessing import RobustScaler
from sklearn.preprocessing import MinMaxScaler
from matplotlib import pyplot
import plotly.graph_objects as go
import math
import seaborn as sns
from sklearn.metrics import mean_squared_error
np.random.seed(1)
tf.random.set_seed(1)
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, LSTM, Dropout, RepeatVector, TimeDistributed
from keras import backend
MODELFILENAME = 'MODELS/DNN_12h_TFM'
TIME_STEPS=72 #12h
UNITS=22
DROPOUT=0.779
ACTIVATION='sigmoid'
OPTIMIZER='adamax'
EPOCHS=85
BATCHSIZE=23
VALIDATIONSPLIT=0.2
# Code to read csv file into Colaboratory:
# from google.colab import files
# uploaded = files.upload()
# import io
# df = pd.read_csv(io.BytesIO(uploaded['SentDATA.csv']))
# Dataset is now stored in a Pandas Dataframe
df = pd.read_csv('../../data/dadesTFM.csv')
df.reset_index(inplace=True)
df['Time'] = pd.to_datetime(df['Time'])
df = df.set_index('Time')
columns = ['PM1','PM25','PM10','PM1ATM','PM25ATM','PM10ATM']
df1 = df.copy();
df1 = df1.rename(columns={"PM 1":"PM1","PM 2.5":"PM25","PM 10":"PM10","PM 1 ATM":"PM1ATM","PM 2.5 ATM":"PM25ATM","PM 10 ATM":"PM10ATM"})
df1['PM1'] = df['PM 1'].astype(np.float32)
df1['PM25'] = df['PM 2.5'].astype(np.float32)
df1['PM10'] = df['PM 10'].astype(np.float32)
df1['PM1ATM'] = df['PM 1 ATM'].astype(np.float32)
df1['PM25ATM'] = df['PM 2.5 ATM'].astype(np.float32)
df1['PM10ATM'] = df['PM 10 ATM'].astype(np.float32)
df2 = df1.copy()
train_size = int(len(df2) * 0.8)
test_size = len(df2) - train_size
train, test = df2.iloc[0:train_size], df2.iloc[train_size:len(df2)]
train.shape, test.shape
((3117, 7), (780, 7))
#Standardize the data
for col in columns:
scaler = StandardScaler()
train[col] = scaler.fit_transform(train[[col]])
<ipython-input-6-83cecdbc25f8>:4: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy train[col] = scaler.fit_transform(train[[col]]) <ipython-input-6-83cecdbc25f8>:4: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy train[col] = scaler.fit_transform(train[[col]]) <ipython-input-6-83cecdbc25f8>:4: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy train[col] = scaler.fit_transform(train[[col]]) <ipython-input-6-83cecdbc25f8>:4: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy train[col] = scaler.fit_transform(train[[col]]) <ipython-input-6-83cecdbc25f8>:4: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy train[col] = scaler.fit_transform(train[[col]]) <ipython-input-6-83cecdbc25f8>:4: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy train[col] = scaler.fit_transform(train[[col]])
def create_sequences(X, y, time_steps=TIME_STEPS):
Xs, ys = [], []
for i in range(len(X)-time_steps):
Xs.append(X.iloc[i:(i+time_steps)].values)
ys.append(y.iloc[i+time_steps])
return np.array(Xs), np.array(ys)
X_train, y_train = create_sequences(train[[columns[1]]], train[columns[1]])
#X_test, y_test = create_sequences(test[[columns[1]]], test[columns[1]])
print(f'X_train shape: {X_train.shape}')
print(f'y_train shape: {y_train.shape}')
X_train shape: (3045, 72, 1) y_train shape: (3045,)
#afegir nova mètrica
def rmse(y_true, y_pred):
return backend.sqrt(backend.mean(backend.square(y_pred - y_true), axis=-1))
model = Sequential()
model.add(Dense(units=UNITS, input_shape=(X_train.shape[1], X_train.shape[2]), activation='relu'))
model.add(Dense(16, activation='relu'))
model.add(Dropout(rate=DROPOUT))
model.add(Dense(X_train.shape[2],activation=ACTIVATION))
model.compile(optimizer=OPTIMIZER, loss='mae',metrics=[rmse,'mse'])
model.summary()
Model: "sequential" _________________________________________________________________ Layer (type) Output Shape Param # ================================================================= dense (Dense) (None, 72, 22) 44 _________________________________________________________________ dense_1 (Dense) (None, 72, 16) 368 _________________________________________________________________ dropout (Dropout) (None, 72, 16) 0 _________________________________________________________________ dense_2 (Dense) (None, 72, 1) 17 ================================================================= Total params: 429 Trainable params: 429 Non-trainable params: 0 _________________________________________________________________
history = model.fit(X_train, y_train, epochs=EPOCHS, batch_size=BATCHSIZE, validation_split=VALIDATIONSPLIT,
callbacks=[keras.callbacks.EarlyStopping(monitor='val_loss', patience=5, mode='min')], shuffle=False)
Epoch 1/85 106/106 [==============================] - 0s 4ms/step - loss: 0.8608 - rmse: 0.8664 - mse: 1.0375 - val_loss: 1.2577 - val_rmse: 1.2581 - val_mse: 1.7936 Epoch 2/85 106/106 [==============================] - 0s 2ms/step - loss: 0.8373 - rmse: 0.8449 - mse: 0.9904 - val_loss: 1.1946 - val_rmse: 1.1956 - val_mse: 1.6383 Epoch 3/85 106/106 [==============================] - 0s 2ms/step - loss: 0.8173 - rmse: 0.8282 - mse: 0.9534 - val_loss: 1.1363 - val_rmse: 1.1380 - val_mse: 1.5015 Epoch 4/85 106/106 [==============================] - 0s 2ms/step - loss: 0.8011 - rmse: 0.8162 - mse: 0.9253 - val_loss: 1.0822 - val_rmse: 1.0844 - val_mse: 1.3794 Epoch 5/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7888 - rmse: 0.8078 - mse: 0.9050 - val_loss: 1.0364 - val_rmse: 1.0393 - val_mse: 1.2804 Epoch 6/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7797 - rmse: 0.8023 - mse: 0.8908 - val_loss: 1.0004 - val_rmse: 1.0039 - val_mse: 1.2056 Epoch 7/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7737 - rmse: 0.7993 - mse: 0.8814 - val_loss: 0.9745 - val_rmse: 0.9784 - val_mse: 1.1530 Epoch 8/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7686 - rmse: 0.7963 - mse: 0.8723 - val_loss: 0.9546 - val_rmse: 0.9589 - val_mse: 1.1136 Epoch 9/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7635 - rmse: 0.7930 - mse: 0.8639 - val_loss: 0.9392 - val_rmse: 0.9437 - val_mse: 1.0834 Epoch 10/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7593 - rmse: 0.7903 - mse: 0.8564 - val_loss: 0.9274 - val_rmse: 0.9321 - val_mse: 1.0607 Epoch 11/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7558 - rmse: 0.7877 - mse: 0.8506 - val_loss: 0.9178 - val_rmse: 0.9227 - val_mse: 1.0424 Epoch 12/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7511 - rmse: 0.7840 - mse: 0.8418 - val_loss: 0.9099 - val_rmse: 0.9150 - val_mse: 1.0275 Epoch 13/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7471 - rmse: 0.7809 - mse: 0.8349 - val_loss: 0.9033 - val_rmse: 0.9086 - val_mse: 1.0154 Epoch 14/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7422 - rmse: 0.7771 - mse: 0.8267 - val_loss: 0.8980 - val_rmse: 0.9034 - val_mse: 1.0055 Epoch 15/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7393 - rmse: 0.7749 - mse: 0.8219 - val_loss: 0.8939 - val_rmse: 0.8993 - val_mse: 0.9979 Epoch 16/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7351 - rmse: 0.7714 - mse: 0.8148 - val_loss: 0.8906 - val_rmse: 0.8962 - val_mse: 0.9920 Epoch 17/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7317 - rmse: 0.7688 - mse: 0.8088 - val_loss: 0.8882 - val_rmse: 0.8938 - val_mse: 0.9876 Epoch 18/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7294 - rmse: 0.7673 - mse: 0.8056 - val_loss: 0.8862 - val_rmse: 0.8919 - val_mse: 0.9841 Epoch 19/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7277 - rmse: 0.7661 - mse: 0.8027 - val_loss: 0.8847 - val_rmse: 0.8905 - val_mse: 0.9814 Epoch 20/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7253 - rmse: 0.7643 - mse: 0.7979 - val_loss: 0.8834 - val_rmse: 0.8893 - val_mse: 0.9792 Epoch 21/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7233 - rmse: 0.7628 - mse: 0.7957 - val_loss: 0.8824 - val_rmse: 0.8884 - val_mse: 0.9775 Epoch 22/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7219 - rmse: 0.7616 - mse: 0.7928 - val_loss: 0.8816 - val_rmse: 0.8876 - val_mse: 0.9761 Epoch 23/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7202 - rmse: 0.7605 - mse: 0.7905 - val_loss: 0.8810 - val_rmse: 0.8871 - val_mse: 0.9750 Epoch 24/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7184 - rmse: 0.7588 - mse: 0.7875 - val_loss: 0.8804 - val_rmse: 0.8865 - val_mse: 0.9740 Epoch 25/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7173 - rmse: 0.7578 - mse: 0.7849 - val_loss: 0.8799 - val_rmse: 0.8861 - val_mse: 0.9732 Epoch 26/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7158 - rmse: 0.7566 - mse: 0.7822 - val_loss: 0.8795 - val_rmse: 0.8857 - val_mse: 0.9726 Epoch 27/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7143 - rmse: 0.7556 - mse: 0.7807 - val_loss: 0.8791 - val_rmse: 0.8853 - val_mse: 0.9719 Epoch 28/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7135 - rmse: 0.7550 - mse: 0.7792 - val_loss: 0.8788 - val_rmse: 0.8851 - val_mse: 0.9714 Epoch 29/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7126 - rmse: 0.7541 - mse: 0.7783 - val_loss: 0.8786 - val_rmse: 0.8849 - val_mse: 0.9711 Epoch 30/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7114 - rmse: 0.7534 - mse: 0.7765 - val_loss: 0.8784 - val_rmse: 0.8848 - val_mse: 0.9708 Epoch 31/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7116 - rmse: 0.7538 - mse: 0.7765 - val_loss: 0.8783 - val_rmse: 0.8847 - val_mse: 0.9706 Epoch 32/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7107 - rmse: 0.7530 - mse: 0.7746 - val_loss: 0.8781 - val_rmse: 0.8845 - val_mse: 0.9704 Epoch 33/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7112 - rmse: 0.7535 - mse: 0.7763 - val_loss: 0.8780 - val_rmse: 0.8845 - val_mse: 0.9703 Epoch 34/85 106/106 [==============================] - ETA: 0s - loss: 0.7003 - rmse: 0.7433 - mse: 0.77 - 0s 2ms/step - loss: 0.7104 - rmse: 0.7531 - mse: 0.7749 - val_loss: 0.8780 - val_rmse: 0.8845 - val_mse: 0.9702 Epoch 35/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7099 - rmse: 0.7527 - mse: 0.7746 - val_loss: 0.8779 - val_rmse: 0.8844 - val_mse: 0.9701 Epoch 36/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7099 - rmse: 0.7528 - mse: 0.7735 - val_loss: 0.8779 - val_rmse: 0.8844 - val_mse: 0.9701 Epoch 37/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7097 - rmse: 0.7527 - mse: 0.7736 - val_loss: 0.8778 - val_rmse: 0.8844 - val_mse: 0.9701 Epoch 38/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7092 - rmse: 0.7521 - mse: 0.7732 - val_loss: 0.8778 - val_rmse: 0.8844 - val_mse: 0.9701 Epoch 39/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7089 - rmse: 0.7520 - mse: 0.7725 - val_loss: 0.8778 - val_rmse: 0.8844 - val_mse: 0.9700 Epoch 40/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7091 - rmse: 0.7523 - mse: 0.7738 - val_loss: 0.8778 - val_rmse: 0.8845 - val_mse: 0.9701 Epoch 41/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7084 - rmse: 0.7516 - mse: 0.7713 - val_loss: 0.8778 - val_rmse: 0.8845 - val_mse: 0.9702 Epoch 42/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7087 - rmse: 0.7518 - mse: 0.7723 - val_loss: 0.8779 - val_rmse: 0.8846 - val_mse: 0.9704 Epoch 43/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7084 - rmse: 0.7517 - mse: 0.7712 - val_loss: 0.8779 - val_rmse: 0.8847 - val_mse: 0.9705 Epoch 44/85 106/106 [==============================] - 0s 2ms/step - loss: 0.7082 - rmse: 0.7515 - mse: 0.7718 - val_loss: 0.8780 - val_rmse: 0.8847 - val_mse: 0.9705
import matplotlib.pyplot as plt
plt.plot(history.history['loss'], label='MAE Training loss')
plt.plot(history.history['val_loss'], label='MAE Validation loss')
plt.plot(history.history['mse'], label='MSE Training loss')
plt.plot(history.history['val_mse'], label='MSE Validation loss')
plt.plot(history.history['rmse'], label='RMSE Training loss')
plt.plot(history.history['val_rmse'], label='RMSE Validation loss')
plt.legend();
X_train_pred = model.predict(X_train, verbose=0)
train_mae_loss = np.mean(np.abs(X_train_pred - X_train), axis=1)
plt.hist(train_mae_loss, bins=50)
plt.xlabel('Train MAE loss')
plt.ylabel('Number of Samples');
def evaluate_prediction(predictions, actual, model_name):
errors = predictions - actual
mse = np.square(errors).mean()
rmse = np.sqrt(mse)
mae = np.abs(errors).mean()
print(model_name + ':')
print('Mean Absolute Error: {:.4f}'.format(mae))
print('Root Mean Square Error: {:.4f}'.format(rmse))
print('Mean Square Error: {:.4f}'.format(mse))
print('')
return mae,rmse,mse
mae,rmse,mse = evaluate_prediction(X_train_pred, X_train,"LSTM")
LSTM: Mean Absolute Error: 0.5447 Root Mean Square Error: 0.7233 Mean Square Error: 0.5232
model.save(MODELFILENAME+'.h5')
#càlcul del threshold de test
def calculate_threshold(X_test, X_test_pred):
distance = np.sqrt(np.mean(np.square(X_test_pred - X_test),axis=1))
"""Sorting the scores/diffs and using a 0.80 as cutoff value to pick the threshold"""
distance.sort();
cut_off = int(0.9 * len(distance));
threshold = distance[cut_off];
return threshold
for col in columns:
print ("####################### "+col +" ###########################")
#Standardize the test data
scaler = StandardScaler()
test_cpy = test.copy()
test[col] = scaler.fit_transform(test[[col]])
#creem seqüencia amb finestra temporal per les dades de test
X_test1, y_test1 = create_sequences(test[[col]], test[col])
print(f'Testing shape: {X_test1.shape}')
#evaluem el model
eval = model.evaluate(X_test1, y_test1)
print("evaluate: ",eval)
#predim el model
X_test1_pred = model.predict(X_test1, verbose=0)
evaluate_prediction(X_test1_pred, X_test1,"LSTM")
#càlcul del mae_loss
test1_mae_loss = np.mean(np.abs(X_test1_pred - X_test1), axis=1)
test1_rmse_loss = np.sqrt(np.mean(np.square(X_test1_pred - X_test1),axis=1))
# reshaping test prediction
X_test1_predReshape = X_test1_pred.reshape((X_test1_pred.shape[0] * X_test1_pred.shape[1]), X_test1_pred.shape[2])
# reshaping test data
X_test1Reshape = X_test1.reshape((X_test1.shape[0] * X_test1.shape[1]), X_test1.shape[2])
threshold_test = calculate_threshold(X_test1Reshape,X_test1_predReshape)
test1_score_df = pd.DataFrame(test[TIME_STEPS:])
test1_score_df['loss'] = test1_rmse_loss.reshape((-1))
test1_score_df['threshold'] = threshold_test
test1_score_df['anomaly'] = test1_score_df['loss'] > test1_score_df['threshold']
test1_score_df[col] = test[TIME_STEPS:][col]
#gràfic test lost i threshold
fig = go.Figure()
fig.add_trace(go.Scatter(x=test1_score_df.index, y=test1_score_df['loss'], name='Test loss'))
fig.add_trace(go.Scatter(x=test1_score_df.index, y=test1_score_df['threshold'], name='Threshold'))
fig.update_layout(showlegend=True, title='Test loss vs. Threshold')
fig.show()
#Posem les anomalies en un array
anomalies1 = test1_score_df.loc[test1_score_df['anomaly'] == True]
anomalies1.shape
print('anomalies: ',anomalies1.shape); print();
#Gràfic dels punts i de les anomalíes amb els valors de dades transformades per verificar que la normalització que s'ha fet no distorssiona les dades
fig = go.Figure()
fig.add_trace(go.Scatter(x=test1_score_df.index, y=scaler.inverse_transform(test1_score_df[col]), name=col))
fig.add_trace(go.Scatter(x=anomalies1.index, y=scaler.inverse_transform(anomalies1[col]), mode='markers', name='Anomaly'))
fig.update_layout(showlegend=True, title='Detected anomalies')
fig.show()
print ("######################################################")
####################### PM1 ########################### Testing shape: (708, 72, 1) 23/23 [==============================] - 0s 911us/step - loss: 0.7242 - rmse: 0.7753 - mse: 0.8538 evaluate: [0.724249541759491, 0.7753031849861145, 0.8537518382072449] LSTM: Mean Absolute Error: 0.4847 Root Mean Square Error: 0.6917 Mean Square Error: 0.4784
<ipython-input-17-48420fb1aa44>:8: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy test[col] = scaler.fit_transform(test[[col]])
anomalies: (143, 10)
###################################################### ####################### PM25 ########################### Testing shape: (708, 72, 1) 23/23 [==============================] - 0s 780us/step - loss: 0.7529 - rmse: 0.8053 - mse: 0.9157 evaluate: [0.7528522610664368, 0.8053011894226074, 0.9157199263572693] LSTM: Mean Absolute Error: 0.5004 Root Mean Square Error: 0.6848 Mean Square Error: 0.4689
<ipython-input-17-48420fb1aa44>:8: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
anomalies: (138, 10)
###################################################### ####################### PM10 ########################### Testing shape: (708, 72, 1) 23/23 [==============================] - 0s 1ms/step - loss: 0.7806 - rmse: 0.8337 - mse: 0.9640 evaluate: [0.7805656790733337, 0.8336521983146667, 0.9640482068061829]
<ipython-input-17-48420fb1aa44>:8: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
LSTM: Mean Absolute Error: 0.5222 Root Mean Square Error: 0.6746 Mean Square Error: 0.4551
anomalies: (56, 10)
###################################################### ####################### PM1ATM ########################### Testing shape: (708, 72, 1) 23/23 [==============================] - 0s 824us/step - loss: 0.7836 - rmse: 0.8370 - mse: 0.8920 evaluate: [0.7835741639137268, 0.8369598984718323, 0.8920474052429199] LSTM: Mean Absolute Error: 0.5290 Root Mean Square Error: 0.6828 Mean Square Error: 0.4662
<ipython-input-17-48420fb1aa44>:8: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
anomalies: (72, 10)
###################################################### ####################### PM25ATM ########################### Testing shape: (708, 72, 1) 1/23 [>.............................] - ETA: 0s - loss: 0.9135 - rmse: 0.9457 - mse: 0.8962WARNING:tensorflow:Callbacks method `on_test_batch_end` is slow compared to the batch time (batch time: 0.0000s vs `on_test_batch_end` time: 0.0010s). Check your callbacks. 23/23 [==============================] - 0s 867us/step - loss: 0.7747 - rmse: 0.8278 - mse: 0.8784 evaluate: [0.7746664881706238, 0.8277532458305359, 0.8784007430076599] LSTM:
<ipython-input-17-48420fb1aa44>:8: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
Mean Absolute Error: 0.5223 Root Mean Square Error: 0.6840 Mean Square Error: 0.4678
anomalies: (72, 10)
###################################################### ####################### PM10ATM ########################### Testing shape: (708, 72, 1) 23/23 [==============================] - 0s 954us/step - loss: 0.7627 - rmse: 0.8165 - mse: 0.8702 evaluate: [0.7626882195472717, 0.8164966702461243, 0.8702334761619568] LSTM: Mean Absolute Error: 0.5108 Root Mean Square Error: 0.6840 Mean Square Error: 0.4678
<ipython-input-17-48420fb1aa44>:8: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
anomalies: (72, 10)
######################################################